<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('数据库信息单选页')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "sqlbuilder/sbrDatabase";
    var validFlagDatas = [[${@dict.getType('comm_valid_flag')}]];
    var driverTypeDatas = [[${@dict.getType('sbr_driver_type')}]];
    var queryParams = {"validFlag":"1"};

    $(function() {
        var options = {
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            queryParams: queryParams,
            columns: [{
                radio: true
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'databaseName',
                    title: '数据库名称'
                },
                {
                    field: 'host',
                    title: '数据库地址'
                },
                {
                    field: 'port',
                    title: '端口号'
                },
                {
                    field: 'driverType',
                    title: '数据库版本',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(driverTypeDatas, value);
                    }
                },
                {
                    field: 'validFlag',
                    title: '有效标识',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(validFlagDatas, value);
                    }
                }]
        };
        $.table.init(options);
    });

    /* 提交(回调形式-父页面调用子页面) */
    function getSelections() {
        var row = {};
        row.id = $.table.selectFirstColumns()[0];
        var databaseName = $.table.selectColumns("databaseName");
        var host = $.table.selectColumns("host");
        var port = $.table.selectColumns("port");
        row.name = host + ":" + port + "/" + databaseName;
        return [row];
    }
</script>
</body>
</html>